<?php
/**
 * Created by JiangJiaCai.
 * User: Administrator
 * Date: 2017/9/22 0022
 * Time: 16:23
 */

namespace ext\dao;


use App\Models\QdcsArticle;
use ext\lib\BaseDaoImpl;

/**
 * article Dao
 * Class ArticleDaoImpl
 * @package ext\dao
 */
class ArticleDaoImpl extends BaseDaoImpl
{
    public function getPageList(string $entityName, int $pageSize, array $where = [], string $order = 'created_at', string $sort = 'desc')
    {
        return $entityName::where($where)
            ->orderBy($order , $sort)
            ->paginate($pageSize);
    }


    public function getHotPageList(int $pageSize){
        return QdcsArticle::whereNull('img')->where(['is_hot' => 1])->limit($pageSize)->get();
    }

    /**
     * 返回一条有图片的热门信息
     */
    public function getHotOneHasImg(){
        return QdcsArticle::whereNotNull('img')->where([
            'is_hot' => 1
        ])->get();
    }

    /**
     * 获取最新申请流程
     * @return mixed
     */
    public function getOneProcess(){
        return QdcsArticle::where(['cls_id' => 46])->orderByDesc('created_at')->limit(1)->first();
    }
}